<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% content_for :page_title do %><%= join_title @group.name, @context.full_name %><% end %>
<% css_bundle :dashboard %>
<% js_bundle :dashboard %>
<%  @active_tab = "home" %>
<% content_for :auto_discovery do %>
  <% if @context_membership %>
    <%= auto_discovery_link_tag(:atom, feeds_group_format_url(@context_membership.feed_code, :atom), {:title => t('group_atom_feed', "Group Atom Feed")}) %>
  <% elsif @context.available? %>
    <%= auto_discovery_link_tag(:atom, feeds_group_format_url(@context.feed_code, :atom), {:title => t('group_atom_feed', "Group Atom Feed")}) %>
  <% end %>
<% end %>

<% content_for :right_side do %>

  <% if can_do(@context, @current_user, :update) %>
    <div>
      <a href="#" id="edit_group" title="Edit Group" class="Button button-sidebar-wide">
        <i class="icon-edit" role="presentation"></i>
        <%= t 'edit_group',"Edit Group" %>
      </a>
    </div>
  <% end %>
  <% if can_do(@context.announcements.temp_record, @current_user, :create) %>
    <div>
      <a href="<%= group_announcements_path(@context) %>#new" title="Add Announcement" id="add-announcement" class="Button button-sidebar-wide">
        <i class="icon-plus" role="presentation"></i>
        <%= t 'new_announcement', "Announcement" %>
      </a>
    </div>
  <% end %>
  <% locals = {:title => t('coming_up', "Coming Up"), :contexts_to_link_to => @context, :upcoming => true, :period => :one_week} %>
  <% if @current_user %>
    <% cache([@current_user, @context, 'group_upcoming_events' ]) do %>
      {{> views/shared/event_list}}
    <% end %>
  <% else %>
    {{> views/shared/event_list}}
  <% end %>
<% end %>

<div id="group_messages">
  {{> views/shared/dashboard_messages}}
  {{> views/shared/recent_activity}}
</div>

<% js_bundle :student_group_dialog %>
<% js_env({
  :student_mode => true,
  :group => @group.as_json[:group],
  :group_category => @group.group_category.try(:[], :group_category)
})%>
